<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="hotelDictionaryItem"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>

    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }

        .modal-body img {
            width: 100%;
        }
    </style>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">酒店字典明细管理</h1>
                </div>
            </div>
            <div class="row">
                <div class="col-md-3">
                    <ul id="menu" class="list-group">
                        <li class="list-group-item">

                            <a role="button" data-toggle="collapse" data-target="#hotelDictionary_detail">
                                <span>酒店数据字典管理</span>
                            </a>
                            <ul class="in" id="hotelDictionary_detail">

                              <#list dics as dic>
                                  <li value="${(dic.id)!}" class="${(qo.parentId?? && dic.id == qo.parentId)?string('active','')}">
                                      <a href="/hotelDictionaryItem/list.do?parentId=${(dic.id)!}">${(dic.title)!}</a>
                                  </li>
                              </#list>
                            </ul>
                        </li>
                    </ul>
                </div>


                <#if (qo.parentId)??>
                <div class="col-md-9">
                    <form class="form-inline" id="searchForm" action="" method="post">
                        <input type="hidden" id="currentPage" name="currentPage" value="1">
                    <#-- <input type="hidden" name = "parentId" value="${qo.parentId}">-->
                        <a class="btn btn-success btn-edit">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                    </form>
                    <table class="table table-striped table-hover">
                        <tr>
                            <th>编号</th>
                            <th>地点</th>
                            <th>字典明细标题</th>
                            <th>字典明细序号</th>
                            <th>操作</th>
                        </tr>


               <#list result.list as entity >
                   <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.place.name}</td>
                       <td>${entity.title}</td>
                       <td>${entity.sequence}</td>


                       <td>
                           <a class="btn btn-info btn-xs btn-edit" href="#" data-json='${(entity.json)!}'>
                               <span class="glyphicon glyphicon-pencil"></span> 编辑
                           </a>


                           <a class="btn btn-danger btn-xs btn-delete"
                              data-url="/hotelDictionaryItem/delete.do?id=${(entity.id)!}">
                               <span class="glyphicon glyphicon-trash"></span> 删除
                           </a>

                       </td>
                   </tr>
               </#list>
                    </table>
                <#include "../common/page.ftl">
                </div>
                </#if>





    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">酒店字典明细编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/hotelDictionaryItem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" name="id" value="${(entity.id)!}">

                    <div class="form-group">
                        <label class="col-lg-4 control-label">城市：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="place.id">
                                <#list cities as c>
                                    <option value="${c.id}">${c.name}</option>
                                </#list>

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">酒店字典目录：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="parentTitle" readonly />
                            <input type="hidden" name="parentId" />
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-4 control-label">字典明细标题：</label>
                        <div class="col-sm-5">
                            <input type="text" class="form-control" name="title" value="${(entity.title)!}"
                                   placeholder="请输入酒店字典明细标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">字典明细序号：</label>
                        <div class="col-sm-5">
                            <input type="text" class="form-control" name="sequence"
                                   value="${(entity.sequence)!}"
                                   placeholder="请输入酒店字典明细序号">
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">提交</button>
            </div>
        </div>
    </div>
</div>

</body>
<script>
 $(function () {
     //新增编辑操作
     $(".btn-edit").click(function () {

         $("#editForm").get(0).reset();
         var json = $(this).data("json");

         if (json) {
             $("input[name='id']").val(json.id);
             $("select[name='place.id']").val(json.placeId);
             $("input[name='title']").val(json.title);
             $("input[name='sequence']").val(json.sequence);
         }

         var parentTitle = $("#hotelDictionary_detail .active a").html();
         var parentId = $("#hotelDictionary_detail .active").val();
         $("input[name='parentTitle']").val(parentTitle);
         $("input[name='parentId']").val(parentId);

         $("#myModal").modal("show");
     })


     //提交表单
     $(".btn-submit").click(function () {
         $("#editForm").ajaxSubmit(function (data) {
             if (data.success) {
                 $.messager.alert("温馨提示","操作成功,2s之后自动刷新");

                 setTimeout(function () {
                     window.location.reload();
                 },2000);

             }else{
                 alert(data.msg);
             }
         })

     })

     //删除操作
     $(".btn-delete").click(function () {
         var url = $(this).data("url");
         console.log(url);
         $.messager.confirm("温馨提示","确定要执行删除操作吗?后果请自负",function () {
             $.get(url,function (data) {
                 if (data.success) {
                     $.messager.alert("温馨提示","操作成功,2s之后自动刷新");

                     setTimeout(function () {
                         window.location.reload();
                     },2000);

                 }else{
                     alert(data.msg);
                 }
             })
         })
     })
 })
</script>
</html>